package org.shj.springbootdemo.controller;

import java.util.List;

import org.shj.springbootdemo.mapper.UserMapper;
import org.shj.springbootdemo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

	@Value(value="${default.user}") //注入application.properties 中的值
	private String defaultUser;
	
	@Autowired
	private UserMapper userMapper;
	
	@RequestMapping(value="/user/{uid}")
	public User get(@PathVariable String uid){
		System.out.println("defaultUser: " + defaultUser);
		User user = userMapper.findByUserId(uid);		
		return user;
	}
	
	@RequestMapping(value="/user")
	public List<User> getAllUser(){
		return userMapper.findAll();		
	}

	/*@RequestMapping(value = "enableLog")
	public void enableLog(){
		this.getClass().getClassLoader().
	}*/
}
